<!DOCTYPE html>
<html lang="zh-CN">

	<head>
		<meta charset="utf-8">
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<meta name="viewport" content="width=device-width, initial-scale=1">
		<!-- 上述3个meta标签*必须*放在最前面，任何其他内容都*必须*跟随其后！ -->
		<meta name="description" content="">
		<meta name="author" content="">

		<title>后台</title>

		<link href="__PUBLIC__/images/favicon.ico" rel="shortcut icon" />

		<!-- Bootstrap core CSS -->
		<link rel="stylesheet" href="__PUBLIC__/css/bootstrap.min.css" />
                <link rel="stylesheet" href="__PUBLIC__/css/bootstrap-theme.min.css" />
                <link rel="stylesheet" href="__PUBLIC__/css/dashboard.css" />
                <link rel="stylesheet" href="__PUBLIC__/css/bootstrap-switch.css" />
                <link rel="stylesheet" href="__PUBLIC__/css/icheck/all.css" />
                <link rel="stylesheet" href="__PUBLIC__/css/select2/select2.css" />
                <link href="__PUBLIC__/css/select2/select2-bootstrap.min.css" rel="stylesheet" />

	</head>

	<body>
<include file="Common/topNav" />

    <div class="container-fluid">
        <div class="row">
            <include file="Common/leftMenu" />
            <div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main">
                <div class="cont-title clearfix">
                    <div class="title">产品列表</div>
                    <div class="btn-group"><button type="button" id="addGoods"  class="btn">添加产品</button></div>
                </div>
                <form class="jc-search form-inline searchForm" action="{:U('Admin/Goods/goodsList')}" method="post">
                    <div class="form-group">
                        <label>产品名称:</label>
                        <input type="text" class="form-control" name="goods_name" value="{$goods_name}" placeholder="输入产品名称">
                    </div>
                   
                  
                    <div class="form-group">
                        <label>产品分类:</label>
                        <select name="goods_type" id="cateListSelect" style="width: 200px;" >
                            <option value="0">所有分类</option>
                            <volist name="cateList" id="cate">
                                <option <if condition="$goods_type eq $cate['id']">selected="selected"</if> value="{$cate.id}" parent="{$cate.pid}">{$cate.type_name}</option>
                            </volist>
                        </select>
                    </div>
					<div class="form-group">
                        <label>产品标签:</label>
                        <select name="goods_tags" class="form-control" style="width: 200px;" >
                            <option value="0">所有标签</option>
                            <volist name="tagList" id="tl">
                                <option <if condition="$goods_tags eq $tl['tag_name']">selected="selected"</if> value="{$tl.tag_name}">{$tl.tag_name}</option>
                            </volist>
                        </select>
                    </div>
                    
                    <input class="btn" type="submit" value="搜索" />
                </form>
               <div class="table-responsive">
                    <table class="table table-striped table-hover" id="tableData">
                        <thead>
                            <tr>
                                <th>序号</th>
                                <th>产品名称</th>
								<th>产品分类</th>
								<th>产品标签</th>
                                <th>价格</th>
                                <th>积分</th>
                                <th>规格</th>
                                <th>库存</th>
                                <th>添加时间</th>
                                <th>操作</th>
                            </tr>
                        </thead>
                        <tbody>
                        <volist name="list['data']" id="news">
                            <tr>
                                <td>{$i}</td>
                                <td>{$news.goods_name}</td>
                                <td>{$news.goods_type.type_name}</td>
								<td>{$news.goods_tags}</td>
                                <td>{$news.price}</td>
                                <td>{$news.integral}</td>
                                <td>{$news.spec}</td>
                                <td>{$news.stock}</td>
                                <td>{$news.ctime|date='Y-m-d H:i:s',###}</td>
                                <td>
                                    <a href="javascript:void(0)" spec_1="{$news.spec_1}" goodsId="{$news.id}" class="setSpec">规格设置</a> | 
                                    <a href="javascript:void(0)" goodsId="{$news.id}" class="edit">修改</a> | 
                            
                                <a href="javascript:void(0)" goodsId="{$news.id}" class="del">删除</a>
                           
                            </td>
                            </tr>
                        </volist>    
                        </tbody>
                    </table>
                    <div class="page">
                        {$list.page}
                    </div>
                </div>
            </div>
        </div>
    </div>
                <include file="Common/modalHtmls" />
		<script type="text/javascript" src="__PUBLIC__/js/jquery.min.js"></script>
                <script type="text/javascript" src="__PUBLIC__/js/bootstrap.min.js"></script>
                <script type="text/javascript" src="__PUBLIC__/js/bootstrap-switch.js"></script>
                <script type="text/javascript" src="__PUBLIC__/js/icheck.min.js"></script>
                <script type="text/javascript" src="__PUBLIC__/js/common.js"></script>
                <script type="text/javascript" src="__PUBLIC__/js/validator.min.js"></script>
                <script type="text/javascript" src="__PUBLIC__/js/ueditor/ueditor.config.js"></script>
                <script type="text/javascript" src="__PUBLIC__/js/ueditor/ueditor.all.js"></script>
                <script type="text/javascript" src="__PUBLIC__/js/select2/select2.js"></script>
                <script type="text/javascript" src="__PUBLIC__/js/select2tree.js"></script>
		<script type="text/javascript">
                    var Ue = null;
                    
			$("#addGoods").click(function () {
                            common.htmlAjax("{:U('Admin/Goods/addGoods')}", {}, function (html) {
                                $("#commonModal").html(html).modal('toggle');
                            })
                        })
                        
                        $("#tableData .setSpec").click(function(){
                            var goodsId = $(this).attr("goodsId");
                            var spec_1 = $(this).attr("spec_1");
                            if(spec_1 == ""){
                                common.alert("提示", "请先添加产品规格维度!", function () {});
                                return false;
                            }
                            common.htmlAjax("{:U('Admin/Goods/setSpec')}", {goodsId : goodsId}, function (html) {
                                $("#commonModal").html(html).modal('toggle');
                            })

                        })
                        
                        $("#tableData .edit").click(function () {
                            var goodsId = $(this).attr("goodsId");
                            common.htmlAjax("{:U('Admin/Goods/editGoods')}", {goodsId : goodsId}, function (html) {
                                $("#commonModal").html(html).modal('toggle');
                            })
                        })
                        
                        
                        $("#tableData .del").click(function () {
                            var goodsId = $(this).attr("goodsId");
                            common.confirm("提示", "确定删除产品?", function () {
                                common.ajax("{:U('Admin/Goods/delGoods')}", {goodsId : goodsId}, function (data) {
                                    //console.log(data);
                                    common.alert("提示", "产品删除成功!", function () {
                                        common.reload();
                                    });
                                });
                            });
                        });
                        
                        $(function(){
            $("#cateListSelect").select2tree();
        })
		</script>
	</body>

</html>



